﻿<html>
<head>
	<title>Marked</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />

	<!-- Wikilookup references -->
	<link rel="stylesheet" type="text/css" href="css/index.css" />
	<link rel="stylesheet" type="text/css" href="css/googlemap.css" />
	<script type="text/javascript" src="js/index.js"></script>
	<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places&language=vi"></script>
	
    <script>
    var lat, lon, key;
      function initialize() {
    	// Lấy dữ liệu kinh, vĩ độ, khóa kiếm --------------------------- \\
		var z = location.toString().indexOf('#');
		var mySearch = location.toString().substr(z+1);
		var x = mySearch.toString().indexOf('@');
		var y = mySearch.toString().indexOf('$');
		lat = mySearch.toString().substr(0, x);
		lon = mySearch.toString().substr(x + 1, y - x - 1);
		key = mySearch.toString().substr(y + 1);
		// --------------------------------------------------------------- \\
		
        var map = new google.maps.Map(document.getElementById('map_canvas'), {
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          center: new google.maps.LatLng(lat, lon),
          zoom: 15
        });

        var request = {
          reference: key
        };

        var infowindow = new google.maps.InfoWindow();
        var service = new google.maps.places.PlacesService(map);

        service.getDetails(request, function(place, status) {
          if (status == google.maps.places.PlacesServiceStatus.OK) {
            var marker = new google.maps.Marker({map: map, position: place.geometry.location});
            google.maps.event.addListener(marker, 'click', function() {
              infowindow.setContent('<b>'+place.name+'</b><p>'+ place.formatted_address +'<p>');
              infowindow.open(map, this);
            });
          }
        });
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
</head>
<body>
<div id="map_canvas"></div>
</body>
</html>